package com.cxs.mapper;

import com.cxs.pojo.Menu;
import com.cxs.pojo.Role;
import com.cxs.pojo.RoleExample;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface RoleMapper {
    long countByExample(RoleExample example);

    int deleteByExample(RoleExample example);

    int deleteByPrimaryKey(Integer roleId);

    int insert(Role record);

    int insertSelective(Role record);

    List<Role> selectByExample(RoleExample example);

    Role selectByPrimaryKey(Integer roleId);

    int updateByExampleSelective(@Param("record") Role record, @Param("example") RoleExample example);

    int updateByExample(@Param("record") Role record, @Param("example") RoleExample example);

    int updateByPrimaryKeySelective(Role record);

    int updateByPrimaryKey(Role record);

    @Select("select r.* from sys_role r inner join sys_role_user ru on r.role_id = ru.rid where r.available = 1 and ru.uid = #{userId}")
    List<Role> selectByuserId(@Param("userId") Integer userid);

    // 查询当前角色拥有的权限
    List<Menu> selectMenuByRoleId(Integer roleId);

    @Delete("delete from sys_role_menu where rid = #{roleId}")
    int deletehavedMenuByroleId(Integer roleId);

    int insertRoleMenu(@Param("roleId") Integer roleId, @Param("ids") Integer[] ids);
}